<?php
/** 
*
* @author Highway of Life http://startrekguide.com
* @package Develop
* @version $Id: auth_permissions_wiki.php 19 2007-04-18 00:55:25Z highwayoflife $
* @copyright (c) 2007 Star Trek Guide Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

// is the user logged in?
if (!$user->data['is_registered'])
{
    if ($user->data['is_bot'])
    {
        // the user is a bot, send them back to home plate...
        redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
    }
    // the user is not logged in, give them a chance to login here...
    login_box('', 'LOGIN');
}
else if ($user->data['user_type'] != USER_FOUNDER)
{
    trigger_error('NOT_AUTHORISED');
}
$user->add_lang('acp/permissions_phpbb');


$acl = request_var('acl', '');
$type = '';

$action	= sprintf('%sView Admin Permissions%s',		'<a href="' . append_sid("auth_permissions_wiki.$phpEx", 'acl=a') . '">', '<a/>') . '<br />';
$action .= sprintf('%sView Moderator Permissions%s','<a href="' . append_sid("auth_permissions_wiki.$phpEx", 'acl=m') . '">', '<a/>') . '<br />';
$action .= sprintf('%sView User Permissions%s',		'<a href="' . append_sid("auth_permissions_wiki.$phpEx", 'acl=u') . '">', '<a/>') . '<br />';
$action .= sprintf('%sView Forum Permissions%s',	'<a href="' . append_sid("auth_permissions_wiki.$phpEx", 'acl=f') . '">', '<a/>') . '<br />';

if (!empty($acl))
{
    switch ($acl)
    {
        case 'a':
            $type = 'a';
        break;
        case 'm':
            $type = 'm';
        break;
        case 'u':
            $type = 'u';
        break;
		case 'f':
			$type = 'f';
		break;
    }
	
	if ($type)
	{
		header('Content-type:text/plain');
		print '{|border="1" cellspacing="0" cellpadding="3"
! Auth Option
! Auth Usage
! Auth Lang
';
		$sql = 'SELECT auth_option FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option LIKE "' . $type . '_%"';
		$result = $db->sql_query($sql);
		while ($row = $db->sql_fetchrow($result))
		{
			if ($row['auth_option'] == ($type . '_'))
			{
				print "|-\n";
				print "| [[{$row['auth_option']}]]\n";
				print '| <php>$auth->acl_get(\'' . $row['auth_option'] . "');</php>\n";
				print '| ' . $user->lang['permission_type'][$row['auth_option']] . "\n";
			}
			else
			{
				$permission = $row['auth_option'];
				print "|-\n";
				print "| [[$permission]]\n";
				print '| <php>$auth->acl_get(\'' . $row['auth_option'] . "');</php>\n";
				print '| ' . $user->lang['acl_' . $permission]['lang'] . "\n";
			}
		}
		$db->sql_freeresult($result);
		print '|}';
	}
	else
	{
		trigger_error($action);
	}
}
else
{
	trigger_error($action);
}
?>